/*
 * Copyright (C) 2018 The Asiainfo-Ability Authors
 *
 *      Licensed under the Apache License, Version 2.0 (the "License");
 *      you may not use this file except in compliance with the License.
 *      You may obtain a copy of the License at
 *
 *          http://www.apache.org/licenses/LICENSE-2.0
 *
 *      Unless required by applicable law or agreed to in writing, software
 *      distributed under the License is distributed on an "AS IS" BASIS,
 *      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *      See the License for the specific language governing permissions and
 *      limitations under the License.
 */

package org.asiainfo.ability.provider.code;

/**
 * @Author: visen
 * @Date: 2018/1/25
 * @Description:
 */
public enum ServiceErrorCode {

    /**
     * 标准业务异常
     */
    sucess(1, "成功"), invalid_req(2, "请求报文错误"), invalid_resp(3, "应答报文错误"), invalid_ability(4, "未匹配到能力")
    , unknonwn(9, "未知异常") ,missing_memebers(21, "缺少成员信息"), invalid_memberop(22, "成员的操作类型不正确");
    private String name;
    private int value;


    private ServiceErrorCode(int value, String name) {
        this.value = value;
        this.name = name;
    }


    @Override
    public String toString() {
        return this.name;
    }

    public int getValue() {
        return this.value;
    }


    public String getName() {
        return this.name;
    }

    public static ServiceErrorCode valueOf(int value) {
        for (ServiceErrorCode c : ServiceErrorCode.values()) {
            if (c.getValue() == value) {
                return c;
            }
        }
        return null;
    }
}
